﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UtilZ.Dotnet.Ex.Model
{
    /// <summary>
    /// 序列化器接口
    /// </summary>
    public interface ISerializer
    {
        /// <summary>
        /// 将当前对象序列化为目标类型的对象
        /// </summary>
        /// <param name="obj">要序列化的对象</param>
        /// <returns>序列化后的数据</returns>
        object Serialize(object obj);




        /// <summary>
        /// 将目标类型的对象反序列化到当前对象
        /// </summary>
        /// <param name="serializeData">序列化数据</param>
        /// <returns>反序列化后的对象</returns>
        T Deserialize<T>(object serializeData) where T : new();

        /// <summary>
        /// 将序列化数据反序列化到目标类型的对象
        /// </summary>
        /// <param name="serializeData">序列化数据</param>
        /// <param name="targetType">目标类型</param>
        /// <returns>反序列化后的对象</returns>
        object Deserialize(object serializeData, Type targetType);

        /// <summary>
        /// 将序列化数据反序列化到目标类型的对象
        /// </summary>
        /// <param name="targetObj">目标对象</param>
        /// <param name="serializeData">序列化数据</param>
        void Deserialize(object targetObj, object serializeData);
    }
}
